<template>
	<view>
		<div>
			<navitop>
				<i class="iconfont" slot="left-slot" @click="outlot">&#xe667;</i>
				<span slot="center-slot">{{titles}}修改</span>
				<!-- <i class="iconfont " slot="right-slot" @click="add"></i> -->
			</navitop>
		</div>
		<div :style="'padding-top:' + nv_height">
			<div class="bill_sty" v-if="deliver_tpye == 0">
				<div class="bill_list" v-for="(item,index) in dataSorce"
					v-if="item.dataTab == '表头' && showHeaderArray.includes(item.code)">
					<div class=" bill_title">
						{{item.name}}:
					</div>
					<div class="bill_input" @click="choice(item)">
						<input v-model="item.values" disabled />
					</div>
				</div>
			</div>
			<div class="bill_content" v-if="deliver_tpye == 0">
				<div class="bill_content_title">
					加工产品
				</div>
				<div class="bill_manual">
					<div class="bill_manual_choose">
						<!-- <span @click="sweep_code">扫码获取</span> -->
						<span @click="product">选择产品</span>
					</div>
					<!--展示产品-->
					<div class="bill_content" style="margin-top:0px;" v-if="productId">
						<div class="bill_content_list">
							<div class="bill_title">产品编码:</div>
							<div class="bill_input_rst text-left">
								{{productCode}}
							</div>
						</div>
						<div class="bill_content_list">
							<div class="bill_title">产品名称:</div>
							<div class="bill_input_rst text-left">
								{{productName}}
							</div>
					</div>
						</div>
				</div>
			</div>
			<div class="bill_content" v-if="deliver_tpye == 0">
				<div class="bill_content_title">
					入库物料
				</div>
				<div class="bill_manual">

					<div class="bill_manual_choose">
						<span @click="sweep_code">扫码获取</span>
						<span @click="material">选择物料</span>
					</div>

				</div>
			</div>
			<div class="bill_content" v-for="(item,index) in Code_dataSorce" v-if="deliver_tpye == 0"
				@click="content_click(item)">
				<div class="bill_content_list">
					<div class="bill_title">物料编码:</div>
					<div class="bill_input_rst">
						{{item.inventoryCode}}
					</div>
				</div>
				<div class="bill_content_list">
					<div class="bill_title">物料名称:</div>
					<div class="bill_input_rst">
						{{item.inventoryName}}
					</div>
				</div>
				<div class="bill_content_list">
					<div class="bill_title">规格型号:</div>
					<div class="bill_input_rst">
						{{item.inventorySpecification}}
					</div>
				</div>
				<div class="bill_content_list">
					<div class="bill_title">计量单位：</div>
					<div class="bill_input_rst">
						{{item.unitName?item.unitName:item.mainUnitName}}
					</div>
				</div>
				<div class="bill_content_list">
					<div class="bill_title">实收数量:</div>
					<div class="bill_input_rst">
						{{item.baseQuantity}}
					</div>
				</div>
			</div>

			<div v-if="deliver_tpye == 1" class="bill_content">
				<div class="bill_content_list">
					<div class="bill_title">单号：</div>
					<div class="bill_input_rst">
						{{Code_dataSorce.voucherCode}}
					</div>
				</div>
				<div class="bill_content_list">
					<div class="bill_title">时间：</div>
					<div class="bill_input_rst">
						{{Code_dataSorce.voucherDate}}
					</div>
				</div>
				<div class="bill_content_list">
					<div class="bill_title">创建人：</div>
					<div class="bill_input_rst">
						{{Code_dataSorce.chargeUserName}}
					</div>
				</div>
			</div>

			<div v-if="deliver_tpye == 1" style="margin-top: 10px;">明细</div>

			<div class="bill_content_mx" v-for="(val,indexs) in Code_dataSorce.orderDetailList">
				<div class="bill_content_list">
					<div class="bill_title">产品编号：</div>
					<div class="bill_input_rst">
						{{val.no}}
					</div>
				</div>
				<div class="bill_content_list">
					<div class="bill_title">颜色：</div>
					<div class="bill_input_rst">
						{{val.colorName}}
					</div>
				</div>
				<div class="bill_content_list">
					<div class="bill_title">数量：</div>
					<div class="bill_input_rst">
						{{val.quantity}}
					</div>
				</div>
			</div>

			<!-- 	<div class="remarks_style" v-if="deliver_tpye == 0">
					<div class="remarks_txt">备注</div>
					<div class="remarks_inpt">
						<textarea placeholder="填写备注"></textarea>
					</div>
				</div> -->

			<div style="height: 110rpx;"></div>
			<div v-if="deliver_tpye == 0" class="bill_content_button" :style="'width:' + bo_windth" @click="record_up">
				提交审核
			</div>

		</div>

		<!-- 弹窗组件 -->
		<popus ref="alerts">
			<alertcenter @row="row" @closes="closes" :dataSorc="popup_Data"></alertcenter>
		</popus>

		<popus ref="alert_sub">
			<div :style="'width:' + nv_windowWidth + ';'">
				<div class="alert_out">
					<div class="alert_text_title">请输入领料数量</div>
					<div class="alert_text">
						<div class="alert_text_left">数量：</div>
						<div class="alert_text_right"><input v-model="quantity_number" type="number" /></div>
					</div>
					<div class="alert_button" @click='Number_alert(C_Uid)'>
						<button>确定</button>
					</div>
				</div>
			</div>
		</popus>

		<!-- 下拉修改弹窗 -->
		<popus ref="edit_list">
			<div class="conten">
				<div class="conten_edit">
					<div class="conten_edit_type conten_edit_public">
						<div class="conten_edit_left">
							物料编码：
						</div>
						<div class="conten_edit_right">
							{{click_data.inventoryCode}}
						</div>
					</div>
					<div class="conten_edit_type">
						<div class="conten_edit_left">
							物料名称：
						</div>
						<div class="conten_edit_right">
							{{click_data.inventoryName}}
						</div>
					</div>
					<div class="conten_edit_type">
						<div class="conten_edit_left">
							规格型号：
						</div>
						<div class="conten_edit_right">
							{{click_data.inventorySpecification}}
						</div>
					</div>
					<div class="conten_edit_type">
						<div class="conten_edit_left">
							计量单位：
						</div>
						<div class="conten_edit_right">
							{{click_data.unitName?click_data.unitName:click_data.mainUnitName}}
						</div>
					</div>
					<div class="conten_edit_type ">
						<div class="conten_edit_left">
							数量：
						</div>
						<div class="conten_edit_right conten_edit_inputs">
							<div class="conten_edit_input">
								<input v-model="click_data.baseQuantity" type="number" />
							</div>
							<div class="conten_edit_plus">
								<div class="conten_edit_bod conten_edit_right_bod" @click="number_plus">
									+
								</div>
								<div class="conten_edit_bod" @click="number_dom">
									-
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="conten_del" @click="del_list">
					<i class="iconfont icon-shanchu"></i>
				</div>
				<div class="conten_edit_bottom" @click="content_close">
					保&nbsp;&nbsp;存
				</div>
			</div>
		</popus>
		
		
		<!-- 超出最低库存列表 -->
		<popus ref="list_number">
			<view :style="'width:' + bo_windth " >
				<view class="number_list" >
					<view class="number_list_title">
						库存预警
					</view>
					<view class="number_box">
						<view class="number_list_type" v-for="(item,index) in load_list">
							<view class="unmber_flex">
								<view class="number_list_left">
									厂库:
								</view>
								<view class="number_list_right">
									{{item.warehouseName}}
								</view>
							</view>
							<view class="unmber_flex">
								<view class="number_list_left">
									物料:
								</view>
								<view class="number_list_right">
									{{item.inventoryName}}
								</view>
							</view>
							<view class="unmber_flex">
								<view class="number_list_left">
									规格型号:
								</view>
								<view class="number_list_right">
									{{item.inventorySpecification}}
								</view>
							</view>
							<view class="unmber_flex">
								<view class="number_list_left">
									出库数量:
								</view>
								<view class="number_list_right">
									{{item.baseQuantity}}
								</view>
							</view>
							<view class="unmber_flex">
								<view class="number_list_left">
									出库前数量:
								</view>
								<view class="number_list_right">
									{{item.beforeInventoryQuantity}}
								</view>
							</view>
							<view class="unmber_flex">
								<view class="number_list_left">
									出库后数量:
								</view>
								<view class="number_list_right">
									{{item.afterInventoryQuantity}}
								</view>
							</view>
							<view class="unmber_flex">
								<view class="number_list_left">
									最低库存:
								</view>
								<view class="number_list_right" style="color: red;">
									{{item.minStorage}}
								</view>
							</view>
						</view>
					</view>
					<view class="number_list_bottom">
						<view class="number_list_txt" style="background-color: #555555;" @click="numberout">
							取消入库
						</view>
						<view class="number_list_txt" @click="numbercontinue">
							继续入库
						</view>
					</view>
				</view>
			</view>
		</popus>


		<!-- 选择物料 -->
		<popus ref="bill_alert">
			<div :style="'width:' + bo_windth " class="bill_wiat">
				<billde @bill_end="bill_end"></billde>
			</div>
		</popus>

		<!-- 选择产品 -->
		<popus ref="science_alert">
			<div :style="'width:' + bo_windth " class="bill_wiat">
				<secience @science_end="science_end"></secience>
			</div>
		</popus>



		<!-- 扫码 -->
		<moncode :Scan_code="scancode"></moncode>
	</view>
</template>

<script>
	import navitop from '@/components/common/navi-top'
	import billde from '@/components/common/bill/bill-details-alert.vue'
	import secience from '@/pages/common/index/purchase/science/alert/science-alert.vue'
	import alertcenter from '@/pages/common/common/alert/alertcenter'
	import popus from '@/uni_modules/uni-popup/components/uni-popup/uni-popup'
	import moncode from "@/components/dumenghanfeng-monitorScanCode/monitorScanCode.vue"
	import {
		current_time
	} from "@/common/api/common/public_api.js"
	import {
		list,
		listhouses,
		pageList,
		pageForVoucher,
		getList,
		inventorypageList,
		recordsave,
		ForVoucher,
		BarCode,
		nssave,
		savecode,
		eliverysave,
		saveAndConfirm,
		pickApplySave,
		DynamicById
	} from '@/common/api/job/bill.js'
	export default {
		components: {
			navitop,
			alertcenter,
			popus,
			moncode,
			billde,
			secience
		},
		data() {
			return {
				titles: '',
				nv_height: '',
				nv_windowWidth: '',
				bo_windth: '',
				dataSorce: '', // 获取表字段
				popup_Data: [], // 获取弹窗数据
				data_curl_rst: {
					current: 1,
					size: 10,
					keyWord: '',
					'page.current': 1,
					'page.size': 10

				},
				showHeaderArray: ['warehouseId', 'purchaseTypeId', 'vendorId', 'crmId', 'businessType',''], //表头显示字段

				Code_dataSorce: [], // 获取用户扫码结果

				scancode: 'Warehouse', // 扫码自定义事件

				curl_data: '',

				quantity_number: '',

				baseQuantity: '',

				C_Uid: '', // 区分数量(那个的)

				D_code: '', // 分类

				title_data: [], //扫码数组却从

				deliver_tpye: 0,

				rundata: 0,

				mainId: null, // 发货单主表ID
				detaiMap: new Map(),

				click_data: '',
				productName: null, //加工产品名称
				productCode: null, //加工产品编码
				productId: null,
				
				isCheckInventoryInfo: true,	// 是否检查最低库存
				
				load_list: [],	// 最低库存列表
				
				numberType: false,	// 防止重复点击提交数据错乱
				
				thisData: {}, // 重复点击历史记录
			}
		},
		onLoad(option) {
			console.log(option)
			
			this.D_code = option.code;
			this.curl_data = option;
			this.titles = option.title;
			if (option.code == "NSSaleDispatchVoucher") {
				this.deliver_tpye = 1;
			}
			let _this = this;

			//判断是否显示业务类型
			if (this.curl_data.c_code > 0) {
				this.showHeaderArray = this.showHeaderArray.filter(res => res != 'businessType');
			}


			uni.$off(this.scancode);
			uni.$on(this.scancode, function(rst) {
				console.log('扫码结果', rst.msg)
				// 扫码去重
				if (option.code == "NSSaleDispatchVoucher") {
					if (_this.title_data.length == 0) {
						_this.title_data.push(rst.msg);
						_this.deliver_list(rst.msg);
					}
					if (_this.title_data.indexOf(rst.msg) == -1) {
						_this.deliver_list(rst.msg);
						_this.title_data.push(rst.msg);
					}
				} else {
					if (_this.title_data.length == 0) {
						_this.title_data.push(rst.msg);
						_this.inventory_list(rst.msg);
					}
					if (_this.title_data.indexOf(rst.msg) == -1) {
						_this.inventory_list(rst.msg);
						_this.title_data.push(rst.msg);
					}
				}
			})
		},



		mounted() {
			this.nv_height = uni.getSystemInfoSync().statusBarHeight + 60 + 'px';

			this.nv_windowWidth = uni.getSystemInfoSync().windowWidth - 20 + 'px';

			this.bo_windth = uni.getSystemInfoSync().windowWidth + 'px';

			this.bill_list();

		},

		methods: {

			// 返回 
			outlot() {
				uni.navigateTo({
					url: '/pages/common/index/purchase/common?title=' + this.curl_data.title + '&code=' + this
						.curl_data.code + '&sort=' + this.curl_data.sort + '&c_code=' + 1 + '&key=' + this
						.curl_data.key + '&search_code=' + this.curl_data.search_code
				})
			},
			
			//修改数据回显currentId: 219 source: DelegateRRS dataSource: DelegateRRS isMyWarehouse: true
			Echo_data_list(){
				let url_str = {};
				if(this.curl_data.code == 'DelegateRRS'){
					url_str = {currentId: this.curl_data.id, source: this.curl_data.code, dataSource: this.curl_data.code , isMyWarehouse: true}
				}
				
				DynamicById(url_str).then((rows) => {
					if(rows.code == 200){
						console.log(rows)
					}
				})
			},

			// 选择产品
			product() {
				this.$refs.science_alert.open('right')
			},

			// 选择产品弹窗关闭
			science_end(val) {
				console.log('选择的产品:', val)
				this.$refs.science_alert.close();
				this.productName = val.inventoryName; //加工产品名称
				this.productCode = val.inventoryCode; //加工产品编码
				this.productId = val.id;
			},


			// 点击添加数量
			number_plus() {
				if (Number(this.click_data.baseQuantity) > 0) {
					this.click_data.baseQuantity = Number(this.click_data.baseQuantity) + 1;
				} else {
					this.click_data.baseQuantity = Number(this.click_data.baseQuantity) - 1;
				}
			},

			// 点击减少数量
			number_dom() {
				if (Number(this.click_data.baseQuantity) > 0) {
					this.click_data.baseQuantity = Number(this.click_data.baseQuantity) - 1;
				} else {
					this.click_data.baseQuantity = Number(this.click_data.baseQuantity) + 1;
				}
			},

			// 弹窗保存
			content_close() {
				this.$refs.edit_list.close();
			},

			//  点击获取数据
			content_click(val) {
				this.click_data = val;
				this.$refs.edit_list.open('bottom')
			},

			// 点击删除
			del_list() {
				for (let i = 0; i < this.Code_dataSorce.length; i++) {
					if (this.click_data.id == this.Code_dataSorce[i].id) {
						this.Code_dataSorce.splice(i, 1);
					}
				}
				this.$refs.edit_list.close();
			},

			// 获取选中物料
			bill_end(val) {
				if (val) {
					console.log(val)
					this.C_Uid = val.id;
					this.Code_dataSorce.push(val)
					this.$refs.alert_sub.open('center');
				}
				this.$refs.bill_alert.close();
			},

			// 点击获取物料信息
			material() {
				this.$refs.bill_alert.open('right')
			},

			// 点击获取扫码(相机)
			sweep_code() {
				// uni.removeStorageSync('details_dataSorce');
				let _this = this;
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						_this.inventory_list(res.result);
					}
				});
			},

			// 获取发货单数据
			deliver_list(data) {
				const {
					mainId,
					detaiMap
				} = this;

				let _this = this;
				let data_run = {};

				if (mainId) {
					data_run = {
						barcode: data,
						mainId
					};
				} else {
					data_run = {
						barcode: data
					};
				}


				// 发货添加
				savecode(data_run).then((rows) => {
					if (rows.code == 200) {
						this.rundata = 1;
						let detail = rows.data.orderDetailList[0];
						let sourceDetailId = rows.data.orderDetailList[0].sourceDetailId;

						if (mainId) {
							let oldDetail = detaiMap.get(sourceDetailId);
							if (oldDetail) {
								console.log('找到明细')
								oldDetail.quantity = detail.quantity;
							} else {
								detaiMap.set(sourceDetailId, detail);

								this.Code_dataSorce.orderDetailList.push(detail);
							}
						} else {
							this.Code_dataSorce = rows.data;
							detaiMap.set(sourceDetailId, detail);
							this.mainId = rows.data.id;
						}
					} else {
						console.log(rows)
					}
				}).catch((e) => {
					uni.showToast({
						title: '提示'
					})
				})

			},

			// 扫码获取物料
			inventory_list(val) {
				let _this = this;
				let code_data = [];
				this.C_Uid = '';
				inventorypageList({
					code: val
				}).then((rows) => {
					if (rows.code == 200) {
						console.log(rows)
						// rows.data.records.filter((item) => {
						// 	_this.C_Uid = item.id;
						// 	_this.Code_dataSorce.push(item);
						// })
						this.C_Uid = rows.data.id;
						this.Code_dataSorce.push(rows.data)

						if (code_data) {
							code_data.filter(item => {
								_this.Code_dataSorce.push(item)
							})
						}

						this.$refs.alert_sub.open('center');
					}
				})
			},

			//	点击获取输入数量
			Number_alert(val) {
				this.baseQuantity = this.quantity_number;
				let _this = this;
				this.Code_dataSorce.forEach((item) => {
					if (item.id == _this.C_Uid) {
						this.$set(item, 'baseQuantity', _this.quantity_number);
					}
				})
				console.log(this.Code_dataSorce)
				this.$refs.alert_sub.close();
				this.quantity_number = '';
			},

			// 修改数量
			Nub_alert(val) {
				this.C_Uid = val.id;
				this.$refs.alert_sub.open('center');
			},

			// 获取列表字段
			bill_list() {
				let _this = this;
				let pot = {};
				list({
					source: this.D_code
				}).then((rows) => {
					if (rows.code == 200) {
						this.dataSorce = rows.data;
						this.Echo_data_list();
					}
				})
			},

			// 弹窗处理(数据处理)
			choice(val) {
				this.popup_Data = [];
				if (val.code == "warehouseId") {
					this.warehouse_list(val.code);
				}
				if (val.code == 'purchaseTypeId') {
					this.purchase_list(val.code);
				}
				if (val.code == 'vendorId') {
					this.voucher_list(val.code);
				}
				if (val.code == 'businessType') {
					let run = JSON.parse(val.val);
					run.forEach((item) => {
						this.$set(item, 'name', item.label);
						this.$set(item, 'id', item.key);
						this.$set(item, 'code', 'businessType');
					})
					this.popup_Data = run;
				}
				if (val.code == 'crmId') {
					this.User_list('crmId');
				}
				if (val.code == "voucherType") {
					let run = JSON.parse(val.val);
					run.forEach((item) => {
						this.$set(item, 'name', item.label);
						this.$set(item, 'id', item.key);
						this.$set(item, 'code', 'voucherType');
					})
					this.popup_Data = run;
				}
				this.$refs.alerts.open('bottom');
			},

			// 弹窗处理(获取弹窗结果)
			row(val) {
				let pot = {};
				if (val.code !== 'businessType') {

					if (val.code == 'voucherType') {
						this.dataSorce.filter((item) => {
							if (item.code == val.code) {
								this.$set(item, 'values', val.name)
								this.$set(item, 'value', val.id)
							}
						})
					} else {
						pot['value'] = val.name;
						pot['code'] = val.code.split('Id')[0] + 'Name';
						this.dataSorce.filter((item) => {
							if (item.code == val.code) {
								if (val.code.substr(val.code.length - 2, 2) == 'Id') {
									this.$set(item, 'values', val.name)
									this.$set(item, 'value', val.id)
								} else {
									this.$set(item, 'value', val.name)
								}
							}
						})
					}


					this.dataSorce.push(pot);
				} else {

					this.dataSorce.filter((item) => {
						if (item.code == val.code) {
							this.$set(item, 'values', val.name);
							this.$set(item, 'value', val.id);
						}
					})
				}
				this.$refs.alerts.close();
			},

			// 获取客户
			User_list(valCode) {
				let _this = this;
				ForVoucher({
					current: 1,
					size: 10,
					isFinance: 1,
					companyType: 'isCustomer',
					'page.current': 1,
					'page.size': 10
				}).then((rst) => {
					if (rst.code == 200) {
						rst.data.records.filter((item) => {
							_this.popup_Data.push({
								name: item.crmName,
								code: valCode,
								id: item.id
							})
						})
					}
				})
			},

			// 获取厂库
			warehouse_list(valCode) {
				let _this = this;
				listhouses(this.data_curl_rst).then((rst) => {
					if (rst.code == 200) {
						rst.data.records.filter((item) => {
							_this.popup_Data.push({
								name: item.whName,
								code: valCode,
								id: item.id,
								whCode: item.whCode
							})
						})
					}
				})
			},

			// 获取采购列表
			purchase_list(valCode) {
				let _this = this;
				pageList(this.data_curl_rst).then((rows) => {
					if (rows.code == 200) {
						rows.data.records.filter((item) => {
							_this.popup_Data.push({
								name: item.name,
								code: valCode,
								id: item.id,
								D_Code: item.code
							})
						})
					}
				})
			},

			// 获取供应商
			voucher_list(valCode) {
				let _this = this;
				let coucherdata = {
					current: 1,
					size: -1,
					isFinance: 1,
					companyType: 'isSupplier',
					'page.current': 1,
					'page.size': -1
				};
				pageForVoucher(coucherdata).then((rows) => {
					if (rows.code == 200) {
						rows.data.records.filter((item) => {
							_this.popup_Data.push({
								name: item.crmName,
								code: valCode,
								id: item.id,
								D_Code: item.crmNo
							})
						})
					}
				})
			},

			// 提交
			record_up() {
				let dats = {};
				
				if(!this.numberType){
						
					this.numberType = true;
				
				this.dataSorce.filter((item) => {
					dats[item.code] = item.value;
				})

				dats['receiveDeliverType'] = this.curl_data.c_code;
				dats['orderDetailList'] = this.Code_dataSorce;
				dats['dataSource'] = this.D_code;
				dats['voucherDate'] = current_time();
				if (this.curl_data.c_code == 0) {
					dats['receiveDeliverType'] = 2;
				}
				if (this.curl_data.c_code == 1) {
					dats['inDate'] = current_time();
					// dats['receiveDeliverType'] = this.curl_data.c_code;
					console.log(3)
					if (this.curl_data.code == "OtherReceiveVoucher") {
						dats['businessType'] = 12;
					}
				}
				if (this.curl_data.c_code == 2) {
					dats['deliveryDate'] = current_time();
					console.log(2)
					if (this.curl_data.code == 'PurchaseReceiveVoucher') {
						dats['voucherState'] = 1;
					}
				}
				if (this.curl_data.c_code == 3) {
					dats['businessType'] = 99;
					console.log(1)
				}

				if (this.curl_data.typeMenu == 4) {
					// alert(1)
					//领料出库
					dats['businessType'] = 0;
				}
				if (this.curl_data.typeMenu == 5) {
					// alert(2)
					//领料出库
					dats['businessType'] = 5;
				}
				console.log(dats)
				if (!this.productId) {
					uni.showToast({
						title: '请选择产品',
						icon: "error"
					})
					return;
				}
				if (dats.orderDetailList.length == 0) {
					uni.showToast({
						title: '请选择物料',
						icon: "error"
					})
					return;
				}
				dats.orderDetailList.forEach(item => {
					item.productId = this.productId;
					item.productName = this.productName;
					item.productCode = this.productCode;
					
					
					this.$set(item, 'inventoryId', item.id);
					if (item.unitType == "单计量") {
						this.$set(item, 'baseUnit', item.unitId)
						this.$set(item, 'unitId', item.unitId)
						this.$set(item, 'baseUnitName', item.unitName)
					} else {
						this.$set(item, 'baseUnit', item.mainUnit)
						this.$set(item, 'unitGroupId', item.unitGroupId)
						this.$set(item, 'baseUnitName', item.mainUnitName)
					}
					
					
					delete item.id;
				})
				
				
					this.thisData = dats;
					// console.log(dats)
				}else{
					dats = this.thisData;
				} 
				
				if(this.curl_data.code == "MaterialDispatchVoucher" && this.curl_data.c_code == 1){
					recordsave(dats).then((rows) => {
						if(rows.code == 200){
							this.url_Jump();
						} else {
							uni.showToast({
								title: rows.message,
								icon: "none"
							})
						}
					})
					
				}else if(this.curl_data.code == 'DelegateRRS') {
					dats['businessType'] = 4;
					pickApplySave(dats).then((rows) => {
						if(rows.code == 200){
							this.url_Jump();
						} else {
							uni.showToast({
								title: rows.message,
								icon: "none"
							})
						}
					})
				}else if(this.curl_data.code == 'DelegateDispatchVoucher') {
					if(this.curl_data.c_code == 2){
						dats['businessType'] = 4;
					}else {
						dats['businessType'] = 5;
					}
					recordsave(dats).then((rows) => {
						if(rows.code == 200){
							console.log(rows)
						}
					})
					
				}else {
					saveAndConfirm(dats).then((rows) => {
						if (rows.code == 200) {
							this.url_Jump();
						} else if(rows.code == 5002){
							this.isCheckInventoryInfo = false;
							this.load_list = JSON.parse(rows.message);
							this.$refs.list_number.open('center');
							
						} else{
							uni.showToast({
								title: rows.message,
								icon: "none"
							})
						}
					})
				}
			},

			// 路由跳转
			url_Jump() {
				uni.showToast({
					title: '提交成功！'
				})
				setTimeout(() => {
					// uni.navigateBack()
					uni.navigateTo({
						url: '/pages/common/index/purchase/common?title=' + this.curl_data.title +
							'&code=' + this.curl_data.code + '&sort=' + this.curl_data.sort + '&c_code=' +
							this.curl_data.c_code + '&key=' + this.curl_data.key + '&search_code=' + this
							.curl_data.search_code + '&typeMenu=' + this.curl_data.typeMenu
					})
				}, 1500)
			},
			// 取消
			numberout(){
				 this.isCheckInventoryInfo = true;
				this.$refs.list_number.close();
			},
			
			// 确定入库
			numbercontinue(){
				this.record_up();
			}
		}
	}
</script>

<style scoped lang="scss">
	
	
	.number_list {
		width: 95%;
		margin: auto;
		background-color: #fff;
		border-radius: 4px;
		height: 500px;
		
		.number_list_title {
			text-align: center;
			padding: 5px 0;
		}
		.number_box {
			height: 410px;
			overflow-y: scroll;
		}
		
		.number_list_type {
			padding: 5px 0;
			border-bottom: 1px solid #cacaca;
			.unmber_flex {
				display: flex;
			}
			.number_list_left {
				width: 100px;
				text-align: right;
				padding: 0 5px 0 0;
				overflow: hidden;
				white-space: nowrap;
			}
			.number_list_right {
				overflow: hidden;
			}
		}
		
		.number_list_bottom {
			display: flex;
			justify-content: space-around;
		}
		.number_list_txt {
			background-color: #007AFF;
			color: #fff;
			text-align: center;
			padding: 5px 10px;
			border-radius: 4px;
			box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
		}
	}
	
	.alert_text_title {
		padding: 10px 0 10px 30rpx;
		font-size: 20px;
		border-bottom: 1px solid #cacaca;
	}

	.bill_wiat {
		width: 100%;
		height: 100%;
		background-color: #fff;
	}


	.remaks_data {
		height: 90rpx;
		line-height: 90rpx;
		text-align: center;
		color: #cacaca;
	}

	// 产品选择样式
	.bill_manual {
		background-color: #fff;
		text-align: center;
		width: 100%;
		margin: auto;
	}

	.bill_manual_choose {
		border-top: 1px solid #cacaca;
		padding: 10px 0 0 0;
		width: 95%;
		margin: auto;
		height: 90rpx;
		line-height: 90rpx;

		span {
			padding: 1% 8% 1% 8%;
			border-radius: 4px;
			background-color: #007AFF;
			color: #fff;
			margin: 10px;
		}
	}

	// 备注模块

	.remarks_inpt {
		width: 95%;
		margin: auto;
		padding: 0 0 90rpx 0;

		textarea {
			width: 100%;
			height: 120rpx;
			margin: 10px 0 10px 0;
		}
	}

	.remarks_txt {
		width: 95%;
		margin: auto;
		height: 60rpx;
		line-height: 60rpx;
		border-bottom: 1px solid #cacaca;
	}

	.remarks_style {
		margin: 10px 0 0 0;
		background-color: #fff;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
	}


	.bill_content_button {
		height: 90rpx;
		line-height: 90rpx;
		background-color: rgb(34, 131, 228);
		text-align: center;
		color: #fff;
		border-radius: 4px;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
		margin: 10px 0 0 0;
		position: fixed;
		bottom: 0;
	}

	.alert_button {
		padding: 0 0 5px 0;

		button {
			width: 60%;
			background-color: rgb(34, 131, 228);
			color: #fff;
		}
	}

	.alert_out {
		background-color: #fff;
		border-radius: 4px;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
	}

	.alert_text {
		display: flex;
		width: 100%;
		height: 90rpx;
		line-height: 90rpx;
		margin: 10px 0 10px 0;
		padding: 10px 0 10px 0;
	}

	.alert_text_left {
		width: 30%;
		text-align: right;
	}

	.bill_sty {
		background-color: #fff;
		padding: 10px 0 10px 0;
	}

	.bill_list {
		width: 90%;
		margin: auto;
		height: 70rpx;
		line-height: 70rpx;
		padding: 0 0 0 30rpx;
		display: flex;
	}

	.bill_title {
		width: 30%;
		overflow: hidden;
		text-align: left;
	}

	.alert_text_right {
		width: 68%;

		input {
			border: 1px solid #cacaca;
			width: 90%;
		}
	}

	.bill_input {
		width: 65%;

		input {
			width: 90%;
			border: 1px solid #cacaca;
			height: 50rpx;
		}
	}

	.bill_input_rst {
		width: 65%;
		margin: 0 0 0 20rpx;
	}

	// 数据列表
	.bill_content {
		background-color: #fff;
		margin-top: 10px;
		padding: 10rpx 0 10px 0;
	}

	.bill_content_mx {
		background-color: #fff;
	}

	.bill_content_list {
		width: 90%;
		margin: auto;
		display: flex;
		height: 60rpx;
		line-height: 60rpx;

		.text-left {
			text-align: left;
		}
	}

	.bill_content_title {
		padding: 10rpx 0 10rpx 30rpx;
		margin-bottom: 5px;
	}


	// 上拉修改弹窗

	.conten_del {
		position: fixed;
		top: 0;
		right: 5%;
		color: red;
		padding: 10px 10px 10px 10px;
		font-size: 20px;
	}

	.conten_edit_input {
		width: 50%;
	}

	.conten_edit_inputs {
		display: flex;
		justify-content: space-between;

		input {
			border: 0;
		}
	}

	.conten_edit_bottom {
		height: 50px;
		line-height: 50px;
		text-align: center;
		background-color: #1890FF;
		color: #fff;
		font-size: 18px;
		border-radius: 4px;
		box-shadow: 0 12px 2px 0 rgba(0, 0, 0, 0.1);
	}

	.conten_edit_public {
		padding-top: 5px;
	}

	.conten_edit_bod {
		border-top: 0 !important;
		border-bottom: 0 !important;
	}

	.conten_edit_right_bod {
		border-right: 0 !important;
	}

	.conten_edit_plus {
		display: flex;
		text-align: center;

		div {
			border: 1px dotted #cacaca;
			width: 80rpx;
		}
	}

	.conten_edit_type {
		display: flex;
		border-bottom: 1px dotted #cacaca;
		// overflow: hidden;
	}

	.conten_edit_left {
		width: 30%;
	}

	.conten_edit_right {
		width: 70%;
	}

	.conten_edit {
		height: 240px;
		width: 90%;
		margin: auto;

		div {
			height: 80rpx;
			line-height: 80rpx;
		}
	}

	.conten {
		width: 100%;
		background-color: #fff;
	}
</style>
